package com.yoda.youdianda.config;

import com.yoda.youdianda.interceptor.TokenInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author shawn
 * @date 2022年 11月 12日 20:11
 */

@Configuration
public class SpringWebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private TokenInterceptor tokenInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截所有请求,token鉴权
        registry.addInterceptor(tokenInterceptor).addPathPatterns("/**").excludePathPatterns(
                "/index/getConfig",
                "/index/login",
                "/index/index",
                "/index/recommend",
                "/index/new",
                "/index/list",
                "/index/hot",
                "/index/show",
                "/index/reg",
                "/error",
                "/home/index/login");
    }
}
